package com.wantong.jianpu.adapters;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.BaseLoadMoreModule;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wantong.jianpu.R;
import com.wantong.jianpu.beans.DeviceListBean;
import com.wantong.jianpu.customviews.CommTextView;

/**
 * @author PACY
 * @date 2022/4/25
 * description:
 */
public class DeviceListAdapter extends BaseQuickAdapter<DeviceListBean.RowsDTO, BaseViewHolder> implements LoadMoreModule {
    CommTextView time_ctv;
    CommTextView num_ctv;
    CommTextView user_ctv;
    CommTextView type_ctv;
    CommTextView area_ctv;
    public DeviceListAdapter() {
        super(R.layout.device_list_item_view);
    }

    @Override
    protected void convert(BaseViewHolder holder, DeviceListBean.RowsDTO s) {


        time_ctv=holder.getView(R.id.time_ctv);
        num_ctv=holder.getView(R.id.num_ctv);
        user_ctv=holder.getView(R.id.user_ctv);
        type_ctv=holder.getView(R.id.type_ctv);
        area_ctv=holder.getView(R.id.area_ctv);

        time_ctv.setContent(s.getStartTime()+"至"+s.getEndTime());
        num_ctv.setContent(s.getCurrentNum()+"/"+s.getInspectionNum());
        user_ctv.setContent(s.getInspectionUserName());
        type_ctv.setContent(s.getInspectionType());
        area_ctv.setContent(s.getInspectionAreaName());

        if(s.getStatus()==2){
            holder.setText(R.id.status_tv,"已完成").setTextColorRes(R.id.status_tv,R.color.blue);
        }else{
            holder.setText(R.id.status_tv,"未完成").setTextColorRes(R.id.status_tv,R.color.secondaryColor);
        }
    }

    @Override
    public BaseLoadMoreModule addLoadMoreModule(BaseQuickAdapter<?, ?> baseQuickAdapter) {
        return new BaseLoadMoreModule(baseQuickAdapter);
    }
}
